﻿package {
	import flash.display.*;
	import flash.events.TimerEvent;
	import flash.events.MouseEvent;
	import flash.utils.Timer;
	import flash.filters.*;
	
	class Starter extends Sprite {
		private var startTimer:Timer;
		private var txt1:TitleTxt;
		private var txt2:TitleTxt;
		private var txt3:TitleTxt;
		private var txt4:TitleTxt;
		private var line34:Sprite;
		private var startbtn:startBtn;
		private var alphaspeed:Number;
		private var xx:int;
		private var yy:int;
		private var xy:int;
		private var lx:Number;
		private var ly:Number;
		private var filter1:DropShadowFilter;
		
		public function Starter(onclick:Function):void {
			alphaspeed=0.03;
			xx=145;
			yy=80;
			xy=72;
			txt1=new TitleTxt();
			txt2=new TitleTxt();
			txt3=new TitleTxt();
			txt4=new TitleTxt();
			line34=new Sprite();
			txt1.gotoAndStop(1);
			txt2.gotoAndStop(2);
			txt3.gotoAndStop(3);
			txt4.gotoAndStop(3);
			txt1.x=xx;//153,86
			txt1.y=yy;
			txt2.x=xx+xy;//225
			txt2.y=yy;
			txt3.x=xx+xy*2;//297
			txt3.y=yy;
			txt4.x=xx+xy*3;//368
			txt4.y=yy;
			line34.x=txt3.x;
			line34.y=txt3.y;
			txt1.alpha=0;
			txt2.alpha=0;
			txt3.alpha=0;
			txt4.alpha=0;
            var color:Number = 0xCCCCCC;
            var angle:Number = 45;
            var alpha:Number = 1;
            var blurX:Number = 8;
            var blurY:Number = 8;
            var distance:Number = 15;
            var strength:Number = 15;
            var inner:Boolean = false;
            var knockout:Boolean = false;
            var quality:Number = BitmapFilterQuality.HIGH;
            filter1= new DropShadowFilter(distance,
                                        angle,
                                        color,
                                        alpha,
                                        blurX,
                                        blurY,
                                        strength,
                                        quality,
                                        inner,
                                        knockout);

			txt1.filter=[filter1];
			txt2.filter=[filter1];
			txt3.filter=[filter1];
			txt4.filter=[filter1];
			addChild(txt1);
			addChild(txt2);
			addChild(line34);
			addChild(txt3);
			addChild(txt4);
			lx=txt3.width/2;
			ly=lx;
			line34.graphics.lineStyle(2,0xFFD700);
			line34.graphics.moveTo(lx,ly);
			startbtn=new startBtn();
			startbtn.x=240;
			startbtn.y=200;

			startTimer=new Timer(10);
			startTimer.addEventListener(TimerEvent.TIMER,ontime);
			startTimer.start();
			startbtn.buttonMode=true;
			startbtn.addEventListener(MouseEvent.CLICK,onclick);
		}
		private function ontime(e:TimerEvent) {
			if (txt1.alpha<1) {
				txt1.alpha+=alphaspeed;
			}
			if (txt1.alpha>=1&&txt2.alpha<1) {
				txt2.alpha+=alphaspeed;
			}
			if (txt2.alpha>=1&&txt3.alpha<1) {
				txt3.alpha+=alphaspeed;
			}
			if (txt3.alpha>=1&&txt4.alpha<1) {
				txt4.alpha+=alphaspeed;
			}
			if (txt4.alpha>=1&&lx<=(xy+txt3.width/2)) {
				line34.graphics.lineTo(lx++,ly);
			}
			if(lx>(xy+txt3.width/2)){
				addChild(startbtn);
			}

			//var mc:MovieClip=e.target;
			//mc.x+=10;
		}
	}
}